#{set 'moreScripts'}
	<script type="text/javascript">
	$(document).ready(function(){
		var actionCidades = #{jsAction @Cidades.listarCidadeByEstado(':estado') /}
		var actionBairros = #{jsAction @Bairros.listarBairroByCidade(':cidade')/}
		
		$('#cmb_estado').change(function(){
			
			
			$.get(actionCidades({estado: $('#cmb_estado').val()}), function(data){
				$('#cmb_cidade').html(data);
			});
			
		});	
		
		$('#cmb_cidade').live('change',function(){
			$.get(actionBairros({cidade: $('#cmb_cidade').val()}), function(data){
				$('#cmb_bairro').html(data);
			});
			
		});	
	});
	</script>
	<script type="text/javascript">
	$(document).ready(function()){
	
	});
	</script>
#{/set}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="pt-BR">
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  </head>
  <body>
<fieldset>


         #{field 'imovel.descricao'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
            <label for="${field.name}" class="control-label">Descrição do Imóvel</label>
            <div class="controls">
              <textarea name="${field.name}" class="input-large span7" style="height:100px;">${field.value}</textarea>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.dataPublicacao'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
            <label for="${field.name}" class="control-label">Data de publicação</label>
            <div class="controls">
              <input type="Text" name="${field.name}" value="${field.value}" class="input-medium">
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          
          #{/field}
          
          #{field 'imovel.tipoImovel'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Tipo do Imóvel</label>
            <div class="controls">
              <Select name="${field.name}.id" value="${field.value}" class="input-medium">
             	<option value="-1" selected="selected">Selecione</option>
				#{list tipoImovel, as:'ti'}
                <option value="${ti.id}" ${imovel?.tipoImovel?.equals(ti)?'selected="true"':''}>${ti.descricao}</option>
           		#{/list}
              </Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.transacao'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Transação do Imóvel</label>
            <div class="controls">
              <Select name="${field.name}.id" value="${field.value}" class="input-medium">
             	<option value="-1" selected="selected">Selecione</option>
				#{list transacao, as:'tran'}
                <option value="${tran.id}" ${imovel?.transacao?.equals(tran)?'selected="true"':''}>${tran.descricao}</option>
           		#{/list}
              </Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.valor'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
            <label for="${field.name}" class="control-label">Valor - R$</label>
            <div class="controls">
              <input type="text" name="${field.name}" value="${field.value}" class="input-medium">
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.iptu'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
            <label for="${field.name}" class="control-label">IPTU - R$</label>
            <div class="controls">
              <input type="Text" name="${field.name}" value="${field.value}" class="input-medium">
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.condominio'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
            <label for="${field.name}" class="control-label">Condominio - R$</label>
            <div class="controls">
              <input type="Text" name="${field.name}" value="${field.value}" class="input-medium">
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}    
          
          #{field 'imovel.quartos'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Qtd. Quartos</label>
            <div class="controls">
              <Select type="text" name="${field.name}" value="${field.value}" class="input-medium">
             	<option value="-1" selected="selected">Selecione</option>
             	<option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6+</option>
              </Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.suites'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Qtd. Suites</label>
            <div class="controls">
              <Select type="text" name="${field.name}" value="${field.value}" class="input-medium">
             	<option value="-1" selected="selected">Selecione</option>
             	<option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6+</option>
              </Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.vagasGaragem'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Vagas de Garagem</label>
            <div class="controls">
              <Select type="text" name="${field.name}" value="${field.value}" class="input-medium">
             	<option value="-1" selected="selected">Selecione</option>
             	<option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6+</option>
              </Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.estado'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Estado</label>
            <div class="controls">
              <Select name="${field.name}.id" id="cmb_estado" value="${field.value}" class="input-medium">
             	<option value="-1" selected="selected">Selecione</option>
				#{list estado, as:'est'}
                <option value="${est.id}" ${imovel?.bairro?.cidade?.estado?.equals(est)?'selected="true"':''}>${est.descricao}</option>
           		#{/list}
              </Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.cidade'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Cidade</label>
            <div class="controls">
              <Select name="${field.name}.id" value="${field.value}" id="cmb_cidade" class="input-medium">
             	<option value="-1" selected="selected">Selecione</option>
             	
             	</Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.bairro'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Bairro</label>
            <div class="controls">
              <Select name="${field.name}.id" value="${field.value}" id="cmb_bairro" class="input-medium">
             	<option value="-1" selected="selected">Selecione</option>
             	
              </Select>
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.cep'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
            <label for="${field.name}" class="control-label">CEP</label>
            <div class="controls">
              <input type="Text" name="${field.name}" value="${field.value}" class="input-medium">
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.largura'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
            <label for="${field.name}" class="control-label">Largura</label>
            <div class="controls">
              <input type="text" name="${field.name}" value="${field.value}" class="input-medium">m
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
            <label for="${field.name}" class="control-label"></label>
          </div>
          #{/field}
          
          #{field 'imovel.comprimento'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
            <label for="${field.name}" class="control-label">Comprimento</label>
            <div class="controls">
              <input type="text" name="${field.name}" value="${field.value}" class="input-medium">m
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
            <label for="${field.name}" class="control-label"></label>
          </div>
          #{/field}    
          
          #{field 'imovel.areaTotal'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
            <label for="${field.name}" class="control-label">Área Total</label>
            <div class="controls">
              <input type="text" name="${field.name}" value="${field.value}" class="input-medium">m²
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
            <label for="${field.name}" class="control-label"></label>
          </div>
          #{/field}          
          
          #{field 'imovel.imagem1'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
            <label for="${field.name}" class="control-label">Foto 01</label>
            <div class="controls">
              <input type="file" name="${field.name}" value="${field.value}" class="input-xlarge"> <br />
              <span class="help-block">${errors.forKey(field.name)} Use apenas imagens JPG ou GIF.</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.imagem2'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
            <label for="${field.name}" class="control-label">Foto 02</label>
            <div class="controls">
              <input type="file" name="${field.name}" value="${field.value}" class="input-xlarge"> <br />
              <span class="help-block">${errors.forKey(field.name)} Use apenas imagens JPG ou GIF.</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.imagem3'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
            <label for="${field.name}" class="control-label">Foto 03</label>
            <div class="controls">
              <input type="file" name="${field.name}" value="${field.value}" class="input-xlarge"> <br />
              <span class="help-block">${errors.forKey(field.name)} Use apenas imagens JPG ou GIF.</span>
            </div>
          </div>
          #{/field}
          
          #{field 'imovel.caracteristicas'}
          <div class="control-group ${errors.forKey(field.name)?'error':''}">
          <label for="${field.name}" class="control-label">Caracteristicas</label>
            <div class="controls">
            	#{list caracteristica, as:'ca'}
              	<Input type="checkbox" name="${field.name}.id" value="${ca.id}" ${imovel?.caracteristicas?.contains(ca)?'checked="true"':''}>
              	${ca.descricao}
              	</Input><br>           	
           		#{/list}
              <span class="help-inline">${errors.forKey(field.name)}</span>
            </div>
          </div>
          #{/field}
          
          <div class="form-actions">
            <button class="btn btn-primary" type="submit">Salvar</button>
          </div>
          #{field 'imovel.id'}
          	<input type="hidden" name="${field.name}" value="${field.value}">
          #{/field}
        </fieldset>
        
</body>
</html>